package com.studyroom.controller;

import com.studyroom.dto.Result;
import com.studyroom.dto.RoomMemberDTO;
import com.studyroom.entity.Room;
import com.studyroom.entity.RoomMember;
import com.studyroom.service.RoomMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/room_member")
public class RoomMemberController {
    @Autowired
    private RoomMemberService roomMemberService;
    @RequestMapping("/join")
    public Result join(@RequestBody RoomMemberDTO roomMember){
        return roomMemberService.join(roomMember);
    }
    @PostMapping("/getAll")
    public Result getAll(@RequestParam Long roomId){
        return roomMemberService.getByRoomId (roomId);
    }
    @PostMapping("/offline")
    public Result offline(){
        return roomMemberService.offline ();
    }
    @PostMapping("/refresh")
    public Result refresh(){
        return roomMemberService.refresh();
    }
}
